/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import Util.ApoiarUtil;
import Model.Apoiar;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

/**
 *
 * @author pedro
 */
@ManagedBean(name = "apoiarBean")
@SessionScoped
public class ApoiarBean {
    
    private int cod_usuario;
    private int cod_post;

    public int getCod_usuario() {
        return cod_usuario;
    }

    public void setCod_usuario(int cod_usuario) {
        this.cod_usuario = cod_usuario;
    }

    public int getCod_post() {
        return cod_post;
    }

    public void setCod_post(int cod_post) {
        this.cod_post = cod_post;
    }
    
     public void getUser() {
         HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true);
         String cod = (String) session.getAttribute("cod");
         Apoiar ap= new Apoiar();
         ap.setCodPost(cod_post);
         ap.setCodUsuario(Integer.parseInt(cod));
         ApoiarUtil.apoiar(ap);
            
        }

}
